package com.silverhaze.diamond.client.ui.table;

import javax.swing.*;
import javax.swing.table.TableModel;
import java.awt.*;

/**
 * SystemUser: Babanin
 * Date: 24.07.2008
 * Time: 0:47:26
 */
public abstract class AbstractServiceTable extends JTable {

    protected AbstractServiceTable() {
    }

    public AbstractServiceTable(TableModel dm) {
        super(dm);
        setGridColor(Color.GRAY);
    }

    public int getSelectedRow() {
        int row = super.getSelectedRow();

        if (row >= 0 && row < getRowCount()) {
            if (getAutoCreateRowSorter()) {
                return getRowSorter().convertRowIndexToModel(row);
            }
        }

        return row;
    }
}

